//===========================================================================//
// File:	link.hh                                                          //
// Contents: Interface specification of base Link                            //
//---------------------------------------------------------------------------//
// Copyright (C) Microsoft Corporation. All rights reserved.                 //
//===========================================================================//

#pragma once

#include "Stuff.hpp"

namespace Stuff {

	class Socket;
	class Plug;
	class PlugIterator;
   class Node;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	class Link
		#if defined(_ARMOR)
			: public Stuff::Signature
		#endif
	{
		friend class Plug;
		friend class PlugIterator;

	public:
		//
		//--------------------------------------------------------------------
		//--------------------------------------------------------------------
		//
		virtual
			~Link();
		void
			TestInstance();

		//
		//--------------------------------------------------------------------
		//--------------------------------------------------------------------
		//
		Socket*
			GetSocket()
				{return socket;}
		Plug*
			GetPlug()
				{return plug;}

	protected:
		//
		//--------------------------------------------------------------------
		//--------------------------------------------------------------------
		//
		Link(
			Socket *socket,
			Plug *plug
		);

		//
		//--------------------------------------------------------------------
		//--------------------------------------------------------------------
		//
		void
			ReleaseFromPlug();

		//
		//--------------------------------------------------------------------
		//--------------------------------------------------------------------
		//
		Socket *socket;
		Plug *plug;

	private:
		//
		//--------------------------------------------------------------------
		//--------------------------------------------------------------------
		//
		void
			AddToPlug(Plug *plug);

		//
		//--------------------------------------------------------------------
		//--------------------------------------------------------------------
		//
		Link *nextLink;
		Link *prevLink;
	};

}
